{
    "cells": [
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "# [HW1] Problem 2: A Simple Classification Approach\n",
                "\n",
                "Import necessary Python packages.\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "import numpy as np\n",
                "import matplotlib.pyplot as plt\n"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Part (a)\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# Load the training dataset\n",
                "train_features = np.load(\"train_features.npy\")\n",
                "train_labels = np.load(\"train_labels.npy\").astype(\"int8\")\n",
                "n_train = train_labels.shape[0]\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "def visualize_digit(features, label):\n",
                "    # Digits are stored as a vector of 400 pixel values. Here we\n",
                "    # reshape it to a 20x20 image so we can display it.\n",
                "    plt.imshow(features.reshape(20, 20), cmap=\"binary\")\n",
                "    plt.xlabel(\"Digit with label \" + str(label))\n",
                "    plt.show()\n",
                "\n",
                "# Visualize a digit\n",
                "# visualize_digit(train_features[0,:], train_labels[0])\n",
                "\n",
                "# TODO: Plot three images with label 0 and three images with label 1\n",
                "\n",
                "### start 1 ###\n",
                "\n",
                "### end 1 ###\n"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Part (b)\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# TODO: Solve the linear regression problem, regressing\n",
                "# X = train_features against y = 2 * train_labels - 1\n",
                "\n",
                "# TODO: Report the residual error and the weight vector\n",
                "\n",
                "### start 2 ###\n",
                "\n",
                "### end 2 ###\n"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Part (c)\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# Load the test dataset\n",
                "# It is good practice to do this after the training has been\n",
                "# completed to make sure that no training happens on the test\n",
                "# set!\n",
                "test_features = np.load(\"test_features.npy\")\n",
                "test_labels = np.load(\"test_labels.npy\").astype(\"int8\")\n",
                "\n",
                "n_test = test_labels.shape[0]\n",
                "\n",
                "# TODO: Implement the classification rule and evaluate it\n",
                "# on the training and test set\n",
                "\n",
                "### start 3 ###\n",
                "\n",
                "### end 3 ###\n"
            ]
        },
        {
            "cell_type": "markdown",
            "metadata": {},
            "source": [
                "## Part (e)\n"
            ]
        },
        {
            "cell_type": "code",
            "execution_count": null,
            "metadata": {},
            "outputs": [],
            "source": [
                "# TODO: Implement classification using random features\n",
                "\n",
                "### start 4 ###\n",
                "\n",
                "### end 4 ###\n"
            ]
        }
    ],
    "metadata": {
        "kernelspec": {
            "display_name": "Python 3",
            "language": "python",
            "name": "python3"
        },
        "language_info": {
            "codemirror_mode": {
                "name": "ipython",
                "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.6.3"
        }
    },
    "nbformat": 4,
    "nbformat_minor": 4
}